package de.hsmannheim.poolraumapp.model;

import java.util.List;
import java.util.Set;
import java.util.Observable;

import org.joda.time.LocalDate;
import org.joda.time.LocalTime;

import android.util.Log;

public class RoomQuery extends Observable {
	private static final String TAG = RoomQuery.class.getName();
	
	public static enum WhenDay {
		TODAY, WEEKDAY, DATE
	}
	
	public static enum WhenTime {
		NOW, POINT, SPAN
	}
	
	public static enum Where {
		ANYWHERE, BUILDINGS
	}
	
	public static enum What {
		ANY_OF, ALL_OF
	}
	
	public static enum WhatOS {
		MAC, WINDOWS, LINUX
	}
	
	public static final String DAY = "when.day";
	public static final String WEEKDAY = "when.day.weekday";
	public static final String DATE = "when.day.date";
	
	public static final String TIME = "when.time";
	public static final String TIME_POINT = "when.time.point";
	public static final String FROM = "when.time.span.from";
	public static final String TO = "when.time.span.to";
	
	public static final String WHERE = "where";
	public static final String BUILDINGS = "where.buildings";
	
	public static final String WHAT = "what";
	public static final String OS = "what.os";
	
	private WhenDay day;
	private WhenTime time;
	private int weekday;
	private LocalDate date;
	private LocalTime timePoint;
	private LocalTime from;
	private LocalTime to;
	private Where where;
	private Set<String> buildings;
	private What what;
	private Set<WhatOS> os;
	
	public WhenDay getDay() {
		return day;
	}
	public void setDay(WhenDay whenDate) {
		Log.d(TAG, "whenDate changed to " + whenDate.name());
		this.day = whenDate;
		notifyObserversNow(DAY);
	}
	public WhenTime getTime() {
		return time;
	}
	public void setTime(WhenTime whenTime) {
		Log.d(TAG, "whenTime changed to " + whenTime.name());
		this.time = whenTime;
		notifyObserversNow(TIME);
	}
	public int getWeekday() {
		return weekday;
	}
	public void setWeekday(int weekday) {
		Log.d(TAG, "weekday changed to " + weekday);
		this.weekday = weekday;
		notifyObserversNow(WEEKDAY);
	}
	public LocalDate getDate() {
		return date;
	}
	public void setDate(LocalDate date) {
		Log.d(TAG, "date changed to " + date);
		this.date = date;
		notifyObserversNow(DATE);
	}
	public LocalTime getTimePoint() {
		return timePoint;
	}
	public void setTimePoint(LocalTime timePoint) {
		this.timePoint = timePoint;
		notifyObserversNow(TIME_POINT);
	}
	public LocalTime getFrom() {
		return from;
	}
	public void setFrom(LocalTime from) {
		this.from = from;
		notifyObserversNow(FROM);
	}
	public LocalTime getTo() {
		return to;
	}
	public void setTo(LocalTime to) {
		this.to = to;
		notifyObserversNow(TO);
	}
	public Where getWhere() {
		return where;
	}
	public void setWhere(Where where) {
		this.where = where;
		notifyObserversNow(WHERE);
	}
	
	public void notifyObserversNow(String id) {
		setChanged();
		super.notifyObservers(id);
	}
	public Set<String> getBuildings() {
		return buildings;
	}
	public void setBuildings(Set<String> buildings) {
		this.buildings = buildings;
		notifyObserversNow(BUILDINGS);
	}
	public What getWhat() {
		return what;
	}
	public void setWhat(What what) {
		this.what = what;
		notifyObserversNow(WHAT);
	}
	public Set<WhatOS> getOS() {
		return os;
	}
	public void setOS(Set<WhatOS> os) {
		this.os = os;
		notifyObserversNow(OS);
	}
}
